﻿<div class="row">
    <div class="col-xs-12 col-md-12 col-lg-12">
        <div class="widget">
            <div class="widget-header bg-blue">
            	<i class="widget-icon fa fa-arrow-left"></i>
                <span class="widget-caption">公众号会员</span>
                <div class="widget-buttons">
                    <a href="#" data-toggle="maximize">
                        <i class="fa fa-expand"></i>
                    </a>
                    <a href="#" data-toggle="collapse">
                        <i class="fa fa-minus"></i>
                    </a>
                    <a href="#" data-toggle="dispose">
                        <i class="fa fa-times"></i>
                    </a>
                </div>
            </div>
            <div class="widget-body" style="height: auto;">
				
				<!--  -->
            	<div class="widget-main ">
                    <div class="tabbable">
                        <ul class="nav nav-tabs tabs-flat" id="myTabuser">
                            <li class="active">
                                <a data-toggle="tab" href="#client">
                                	客户
                                </a>
                            </li>
                            <li>
                                <a data-toggle="tab" href="#business">
                                	商户
                                </a>
                            </li>
                            <li>
                                <a data-toggle="tab" href="#auntie">
                                	社区管家
                                </a>
                            </li>
                        </ul>
                        <div class="tab-content tabs-flat">
                            <div id="client" class="tab-pane active">
                                <!-- 客户 -->
								<div class="table-toolbar">
									<form id="bbFormclient">
									 	<div class="col-lg-2 col-sm-2 col-xs-2">
										<div class="input-group input-group-sm">
				                            <input type="text" class="form-control" name="nickname">
				                            	<input type="hidden" class="form-control" name="usertype" value="1">
				                            <span class="input-group-btn">
				                            	<a href="{:U('Admin/Wx/user')}" class="btn btn-primary" data-loader="bb-loader" data-loadername="微信会员" data-search="bbFormclient">
													<i class="fa fa-search"></i>搜索
											</a>
				                            </span>
				                        </div>
				                       </div>
									</form>

									<a href="javascript:;" id="agent_set" class="btn btn-primary"  >
										<i class="fa fa-plus"></i>设为业务员
									</a>
									
								</div>
								
								<table class="table table-hover table-striped table-bordered">
				                    <thead class="bordered-blueberry">
				                        <tr role="row">
				                        	<th style="width: 30px;">
				                        		<div class="checkbox" style="margin-bottom: 0px; margin-top: 0px;">
													<label style="padding-left: 4px;"> <input type="checkbox" class="bb-checkall colored-blue">
				                                     <span class="text"></span>
													</label>                                    
				                                </div>
				                        	</th>
				                        	<th style="width: 80px;">头像</th>
				                        	<th>昵称</th>
				                        	<th>性别</th>
				                        	<th>省-城市</th>
				                        	<th>国家</th>
				                        	<th>用户语言</th>
				                        	<th>关注时间</th>
				                        	<th>备注</th>
				                        	<th>分组</th>
				                        	<th style="width: 125px;">操作</th>
				                        </tr>
				                    </thead>
				                    <tbody>
				                    	<volist name="userclient" id="vo">
				                    		<tr>
				                    			<td>
													<div class="checkbox" style="margin-bottom: 0px; margin-top: 0px;">
														<label style="padding-left: 4px;"> <input name="checkvalue" type="checkbox" class="colored-blue bb-check" value="{$vo.id}">
					                                     <span class="text"></span>
														</label>                                    
					                                </div>
												</td>
				                    			<td align="center"><img src="<if condition="$vo['headimgurl']">{$vo.headimgurl|substr=0,-1}64</if>" width="64px"/></td>
				                    			<td>{$vo.nickname}</td>
				                    			<td>
				                    				<if condition="$vo['sex'] eq 1">
				                    					男
													<elseif condition="$vo['sex'] eq 2"/>
														女
													<else /> 
														未知
													</if>
				                    			</td>
				                    			<td>{$vo.province}-{$vo.city}</td>
				                    			<td>{$vo.country}</td>
				                    			<td>{$vo.language}</td>
				                    			<td>{$vo.subscribe_time|date="Y-m-d H:i:s",###}</td>
				                    			<td>{$vo.remark}</td>
				                    			<td>{$vo.groupname}</td>
				                    			<td align="center">
				                    				<!--<a href="{:U('Admin/Wxmessage/sendmsg',array('id'=>$vo['id']))}" class="btn btn-info btn-xs" data-loader="bb-loader" data-loadername="发送消息" ><i class="fa fa-edit"></i> 发送消息 </a>
				                        			<a href="#" data-id="{$vo.id}" class="btn btn-primary mobile btn-xs"><i class="fa fa-retweet"></i> 移动分组 </a>-->
				                    				<a href="#" data-id="{$vo.id}" data-usertype="1" class="btn btn-primary remark btn-xs"><i class="fa fa-pencil"></i> 设置备注 </a>
				                    			</td>
				                    		</tr>
				                    	</volist>
				                    </tbody>
				                </table>
				                <div class="row DTTTFooter">{$clientpage}</div>
                                <!-- 客户 -->
                            </div>

                            <div id="business" class="tab-pane">
                                <!-- 商户 -->
                                <div class="table-toolbar" style="height:34px;padding: 0px;">
									<form id="bbFormbusiness">
									 	<div class="col-lg-2 col-sm-2 col-xs-2">
										<div class="input-group input-group-sm">
				                            <input type="text" class="form-control" name="nickname">
				                            <input type="hidden" class="form-control" name="usertype" value="2">
				                            <span class="input-group-btn">
				                            	<a href="{:U('Admin/Wx/user')}" class="btn btn-primary" data-loader="bb-loader" data-loadername="微信会员" data-search="bbFormbusiness">
													<i class="fa fa-search"></i>搜索
												</a>
				                            </span>
				                        </div>
				                       </div>
									</form>
								</div>
								
								<table class="table table-hover table-striped table-bordered">
				                    <thead class="bordered-blueberry">
				                        <tr role="row">
				                        	<th style="width: 30px;">
				                        		<div class="checkbox" style="margin-bottom: 0px; margin-top: 0px;">
													<label style="padding-left: 4px;"> <input type="checkbox" class="bb-checkall colored-blue">
				                                     <span class="text"></span>
													</label>                                    
				                                </div>
				                        	</th>
				                        	<th style="width: 80px;">头像</th>
				                        	<th>昵称</th>
				                        	<th>性别</th>
				                        	<th>省-城市</th>
				                        	<th>国家</th>
				                        	<th>用户语言</th>
				                        	<th>关注时间</th>
				                        	<th>备注</th>
				                        	<th>分组</th>
				                        	<th style="width: 125px;">操作</th>
				                        </tr>
				                    </thead>
				                    <tbody>
				                    	<volist name="userbusiness" id="vo">
				                    		<tr>
				                    			<td>
													<div class="checkbox" style="margin-bottom: 0px; margin-top: 0px;">
														<label style="padding-left: 4px;"> <input name="checkvalue" type="checkbox" class="colored-blue bb-check" value="{$vo.id}">
					                                     <span class="text"></span>
														</label>                                    
					                                </div>
												</td>
				                    			<td align="center"><img src="<if condition="$vo['headimgurl']">{$vo.headimgurl|substr=0,-1}64</if>" width="64px"/></td>
				                    			<td>{$vo.nickname}</td>
				                    			<td>
				                    				<if condition="$vo['sex'] eq 1">
				                    					男
													<elseif condition="$vo['sex'] eq 2"/>
														女
													<else /> 
														未知
													</if>
				                    			</td>
				                    			<td>{$vo.province}-{$vo.city}</td>
				                    			<td>{$vo.country}</td>
				                    			<td>{$vo.language}</td>
				                    			<td>{$vo.subscribe_time|date="Y-m-d H:i:s",###}</td>
				                    			<td>{$vo.remark}</td>
				                    			<td>{$vo.groupname}</td>
				                    			<td align="center">
				                    				<!--<a href="{:U('Admin/Wxmessage/sendmsg',array('id'=>$vo['id']))}" class="btn btn-info btn-xs" data-loader="bb-loader" data-loadername="发送消息" ><i class="fa fa-edit"></i> 发送消息 </a>
				                        			<a href="#" data-id="{$vo.id}" class="btn btn-primary mobile btn-xs"><i class="fa fa-retweet"></i> 移动分组 </a>-->
				                    				<a href="#" data-id="{$vo.id}" data-usertype="2" class="btn btn-primary remark btn-xs"><i class="fa fa-pencil"></i> 设置备注 </a>
				                    			</td>
				                    		</tr>
				                    	</volist>
				                    </tbody>
				                </table>
				                <div class="row DTTTFooter">{$businesspage}</div>
                                <!-- 商户 -->
                            </div>
                            
                            <div id="auntie" class="tab-pane">
								<!-- 阿姨 -->
								<div class="table-toolbar" style="height:34px;padding: 0px;">
									<form id="bbForm">
									 	<div class="col-lg-2 col-sm-2 col-xs-2">
										<div class="input-group input-group-sm">
				                            <input type="text" class="form-control" name="nickname">
				                            <input type="hidden" class="form-control" name="usertype" value="3">
				                            <span class="input-group-btn">
				                            	<a href="{:U('Admin/Wx/user')}" class="btn btn-primary" data-loader="bb-loader" data-loadername="微信会员" data-search="bbForm">
													<i class="fa fa-search"></i>搜索
												</a>
				                            </span>
				                        </div>
				                       </div>
									</form>
								</div>
								
								<table class="table table-hover table-striped table-bordered">
				                    <thead class="bordered-blueberry">
				                        <tr role="row">
				                        	<th style="width: 30px;">
				                        		<div class="checkbox" style="margin-bottom: 0px; margin-top: 0px;">
													<label style="padding-left: 4px;"> <input type="checkbox" class="bb-checkall colored-blue">
				                                     <span class="text"></span>
													</label>                                    
				                                </div>
				                        	</th>
				                        	<th style="width: 80px;">头像</th>
				                        	<th>昵称</th>
				                        	<th>性别</th>
				                        	<th>省-城市</th>
				                        	<th>国家</th>
				                        	<th>用户语言</th>
				                        	<th>关注时间</th>
				                        	<th>备注</th>
				                        	<th>分组</th>
				                        	<th style="width: 125px;">操作</th>
				                        </tr>
				                    </thead>
				                    <tbody>
				                    	<volist name="userauntie" id="vo">
				                    		<tr>
				                    			<td>
													<div class="checkbox" style="margin-bottom: 0px; margin-top: 0px;">
														<label style="padding-left: 4px;"> <input name="checkvalue" type="checkbox" class="colored-blue bb-check" value="{$vo.id}">
					                                     <span class="text"></span>
														</label>                                    
					                                </div>
												</td>
				                    			<td align="center"><img src="<if condition="$vo['headimgurl']">{$vo.headimgurl|substr=0,-1}64</if>" width="64px"/></td>
				                    			<td>{$vo.nickname}</td>
				                    			<td>
				                    				<if condition="$vo['sex'] eq 1">
				                    					男
													<elseif condition="$vo['sex'] eq 2"/>
														女
													<else /> 
														未知
													</if>
				                    			</td>
				                    			<td>{$vo.province}-{$vo.city}</td>
				                    			<td>{$vo.country}</td>
				                    			<td>{$vo.language}</td>
				                    			<td>{$vo.subscribe_time|date="Y-m-d H:i:s",###}</td>
				                    			<td>{$vo.remark}</td>
				                    			<td>{$vo.groupname}</td>
				                    			<td align="center">
				                    				<!--<a href="{:U('Admin/Wxmessage/sendmsg',array('id'=>$vo['id']))}" class="btn btn-info btn-xs" data-loader="bb-loader" data-loadername="发送消息" ><i class="fa fa-edit"></i> 发送消息 </a>
				                        			<a href="#" data-id="{$vo.id}" class="btn btn-primary mobile btn-xs"><i class="fa fa-retweet"></i> 移动分组 </a>-->
				                    				<a href="#" data-id="{$vo.id}" data-usertype="3" class="btn btn-primary remark btn-xs"><i class="fa fa-pencil"></i> 设置备注 </a>
				                    			</td>
				                    		</tr>
				                    	</volist>
				                    </tbody>
				                </table>
				                <div class="row DTTTFooter">{$auntiepage}</div>
								<!-- 阿姨 -->
                            </div>
						</div>
					</div>
				</div>
            </div>
        </div>
    </div>
</div>

<!--面包屑导航封装-->
<div id="tmpbread" style="display: none;">{$breadhtml}</div>
<script type="text/javascript">
	setBread($('#tmpbread').html());
</script>

<script type="text/javascript">
	//全选
	var checkall=$('.bb-checkall');
	var checks=$('.bb-check');
	var trs=$('table tbody tr');
	$(checkall).on('click',function(){
		if($(this).is(":checked")){			
			$(checks).prop("checked","checked");
		}else{
			$(checks).removeAttr("checked");
		}		
	});
	$(trs).on('click',function(){
		var c=$(this).find("input[type=checkbox]");
		if($(c).is(":checked")){
			$(c).removeAttr("checked");
		}else{
			$(c).prop("checked","checked");
		}		
	});
	
	//=================================
	var usertype="{$usertype}";
	if(usertype=='1'){
		$('#myTabuser li').removeClass("active");
		$('#myTabuser li').eq(0).addClass("active");
		
		$('#client').removeClass("active");
		$('#business').removeClass("active");
		$('#auntie').removeClass("active");
		$('#client').addClass("active");
	}
	if(usertype=='2'){
		$('#myTabuser li').removeClass("active");
		$('#myTabuser li').eq(1).addClass("active");
		
		$('#client').removeClass("active");
		$('#business').removeClass("active");
		$('#auntie').removeClass("active");
		$('#business').addClass("active");
	}
	if(usertype=='3'){
		$('#myTabuser li').removeClass("active");
		$('#myTabuser li').eq(2).addClass("active");
		
		$('#client').removeClass("active");
		$('#business').removeClass("active");
		$('#auntie').removeClass("active");
		$('#auntie').addClass("active");
	}
	//==================================
	//多选设为开店业务员
	$('#agent_set').on('click',function(){
		var checks=$(".bb-check:checked");
		var chk='';
		$(checks).each(function(){
			chk+=$(this).val()+',';
		});
		if(!chk){
			$.bb.alert('danger','请选择要设置业务员的微信号！');
			return false;
		}
		$.ajax({
			type:"post",
			url:"{:U('Admin/Wx/agent_set')}",
			data:{'ids':chk},
			dataType: "html",
			success:function(mbs){
				bootbox.dialog({
	            	message: mbs,
	            	title: "设置业务员姓名：",
	            	className: "modal-darkorange",
            	});
			},
			error:function(xhr){
				$.bb.alert('danger','通讯失败！请重试！');
			}
		});
	});
	
	//设置会员备注
	$('.remark').on('click',function(){
		var id=$(this).data('id');
		var usertype=$(this).data('usertype');
		$.ajax({
			type:"post",
			url:"{:U('Admin/Wx/remark_set')}",
			data:{'ids':id,'usertype':usertype},
			dataType: "html",
			success:function(mb){
				bootbox.dialog({
	            	message: mb,
	            	title: "设置备注",
	            	className: "modal-darkorange",
            	});
			},
			error:function(xhr){
				$.bb.alert('danger','通讯失败！请重试！');
			}
		});
	});
</script>
